/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.nju.zyy.basic.variation;

/**
 * 
 * @author yingyzhang
 */
public class SimpleThread extends Thread {

	private static int threadCount = 0;

	private int countDown = 5;

	public SimpleThread() {
		// Store the thread name:
		super(Integer.toString(++threadCount));
		// 鍦ㄦ瀯閫犲嚱鏁颁腑鍚姩鏂扮嚎绋嬩細寰堝嵄闄╋紝搴旈伩鍏嶆墽琛屾鎿嶄綔銆� start();
	}

	@Override
	public String toString() {
		return "#" + getName() + "(" + countDown + ").";
	}

	@Override
	public void run() {
		while (true) {
			System.out.println(this);
			if (--countDown == 0) {
				return;
			}
		}
	}

	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			new SimpleThread();
		}
	}

}
